-- Some palindrome functions.

-- Exercise 4.
-- "1234" -> "12344321", "1" -> "11"
toPalindrome (x:xs) = x : toPalindrome xs ++ [x]
toPalindrome _ = []

-- "1234" -> "1234321", "1" -> "1"
anotherToPalindrome (x:xs)
    | xs == [] = [x]
    | otherwise = x : anotherToPalindrome xs ++ [x]
anotherToPalindrome _ = []

-- Exercise 5.
-- Naive version.
isPalindrome (x : xs)
    | xs == [] = True
    | otherwise = x == last xs && isPalindrome (take ((length xs) - 1) xs)
isPalindrome _ = True
